%Figures: occupations

black_rose  =  [116, 5, 60]/256;
orange_roughy =  [198, 69, 33]/256;
horizon          = [93, 129, 155]/256;
blue_marguerite = [103,98,183]/256;
tundora         = [66, 66, 66]/256;
dove_gray = [102, 102, 102]/256;

% earnings data
Occ_w = T{1,7:end}';  
% res benef 8 weeks out:
Br_8 = T{4,7:end}'; % 



%% FIGURE - weekly earnings and potential UI income - by OCCUPATION
scale  = 4;
wratio = 1.30;
posxy  = 1;
lwidth = 2;
fsize  = 22;
Max_earnings        = 1500;
Weekly_Earnings     = [0:50:Max_earnings]';
Weekly_UI           = Weekly_Earnings;
Repl_rate_50        = 0.5*Weekly_Earnings;
Repl_rate_125       = 1.25*Weekly_Earnings;
Baseline_UI         = 0.5*Weekly_Earnings;
Baseline_UI(Baseline_UI>500) = 500;
CARES_UI            = Baseline_UI + 600;
bottom_line         = zeros(length(Weekly_Earnings),1);
top_line         = 4000*ones(length(Weekly_Earnings),1);


figure1=figure;
fsize  = 16;
scale1 = 7;
xyratio = (11.5/14);
set(figure1,'units','inches','position',[posxy posxy wratio*xyratio*scale1 wratio*scale1]);
axes1 = axes('Parent',figure1,'FontSize',fsize);
set(axes1,'units','inches','position',[posxy posxy xyratio*scale1 scale1]);
set(gca, 'FontName', 'Palatino')
%axes1.YGrid = 'on';
set(axes1,'ylim',[0 2250]);
set(axes1,'xlim',[100 Max_earnings]);
set(axes1,'XTick',[100 500 1000 Max_earnings]);
hold on;

% Lower shaded region
x1 = [Weekly_Earnings', fliplr(Weekly_Earnings')];
inBetween = [bottom_line', fliplr(Weekly_Earnings')];
h=fill(x1, inBetween, 'g');
set(h,'EdgeColor','none');
set(h,'FaceColor',color_blue_light);
set(h,'FaceAlpha',0.1);
% 

% Upper shaded region
inBetween3 = [top_line', fliplr(Weekly_Earnings')];
h3=fill(x1, inBetween3, 'g');
set(h3,'EdgeColor','none');
set(h3,'FaceColor',color_green);
set(h3,'FaceAlpha',0.005);

% Indicate deciles
xl1 = xline(Occ_w(1,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl1.Label = 'Management';
xl1.LabelHorizontalAlignment = 'center';
xl1.LabelVerticalAlignment = 'bottom';
%
xl2 = xline(Occ_w(2,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl2.Label = 'Prof., Tech.';
xl2.LabelHorizontalAlignment = 'center';
xl2.LabelVerticalAlignment = 'bottom';
%
xl3 = xline(Occ_w(3,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl3.Label = 'Services   ';
xl3.LabelHorizontalAlignment = 'center';
%xl3.LabelVerticalAlignment = 'bottom';
%
xl4 = xline(Occ_w(4,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl4.Label = 'Sales';
xl4.LabelHorizontalAlignment = 'center';
%
xl5 = xline(Occ_w(5,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl5.Label = 'Admin. ';
xl5.LabelHorizontalAlignment = 'center';
%
xl6 = xline(Occ_w(6,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl6.Label = 'Farm., fish.';
xl6.LabelHorizontalAlignment = 'center';
xl6.LabelVerticalAlignment = 'bottom';
%
xl7 = xline(Occ_w(7,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl7.Label = 'Constr., extract.';
xl7.LabelHorizontalAlignment = 'center';
%xl7.LabelVerticalAlignment = 'bottom';
%
%
xl8 = xline(Occ_w(8,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl8.Label = 'Inst., maint., rep.';
xl8.LabelHorizontalAlignment = 'center';
%
%
xl9 = xline(Occ_w(9,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl9.Label = 'Production';
xl9.LabelHorizontalAlignment = 'center';
xl9.LabelVerticalAlignment = 'bottom';
%
%
xl10 = xline(Occ_w(10,1),'LineWidth',0.5,'Color',black,'Alpha',0.25,'LineStyle','-.','FontSize',11);
xl10.Label = 'Transp., mat.';
xl10.LabelHorizontalAlignment = 'center';
xl10.LabelVerticalAlignment = 'bottom';

 
% 100% replacement rate
plot(Weekly_Earnings,Weekly_UI,'LineWidth',1,'Color',medium_grey);
    xlim=get(gca,'XLim');
    ylim=get(gca,'YLim');
    ht = text(0.27*xlim(1)+0.73*xlim(2),0.475*ylim(1)+0.525*ylim(2),'100 % replacement rate','FontName', 'Palatino');
    set(ht,'Rotation',38)
    set(ht,'FontSize',12)
% 50% replacement rate
plot(Weekly_Earnings,Repl_rate_50,'LineWidth',1,'LineStyle','--','Color',medium_grey);
    ht = text(0.08*xlim(1)+0.92*xlim(2),0.678*ylim(1)+0.327*ylim(2),'50 %','FontName', 'Palatino');
    set(ht,'Rotation',22.5)
    set(ht,'FontSize',12,'Color',black)  
% Baseline UI
%plot(Weekly_Earnings,Baseline_UI,'LineWidth',1.5,'Color',orange_roughy);green_AT
plot(Weekly_Earnings,Baseline_UI,'LineWidth',1.5,'Color',red_AT);
    ht = text(0.2*xlim(1)+0.8*xlim(2),0.8*ylim(1)+0.2*ylim(2),'Regular UI','FontName', 'Palatino');
    set(ht,'Rotation',0)
    set(ht,'FontSize',14)
% CARES UI
%plot(Weekly_Earnings,CARES_UI,'LineWidth',1.5,'Color',frbsf_green);
plot(Weekly_Earnings,CARES_UI,'LineWidth',1.5,'Color',green_AT);
    ht = text(0.2*xlim(1)+0.8*xlim(2),0.535*ylim(1)+0.465*ylim(2),'CARES Act','FontName', 'Palatino');
    set(ht,'Rotation',0)
    set(ht,'FontSize',14)

 % Reservation benefits: 8 weeks  
 p3=plot(Occ_w,Br_8,'o','MarkerSize',10,'MarkerFaceColor',blue_marguerite,'MarkerEdgeColor',blue_marguerite); hold on;
 % 
 p4=plot(Occ_w(3),2500,'o','MarkerSize',10,'MarkerFaceColor',blue_marguerite,'MarkerEdgeColor',blue_marguerite); hold on;
p5=plot(Occ_w(5),2500,'o','MarkerSize',10,'MarkerFaceColor',blue_marguerite,'MarkerEdgeColor',blue_marguerite); hold on;
p6=plot(Occ_w(7),2500,'o','MarkerSize',10,'MarkerFaceColor',blue_marguerite,'MarkerEdgeColor',blue_marguerite); hold on;

%
ylabel('UI ($ per week)')
xlabel('Earnings ($ per week)')
%

% saveas(gcf,'Figures_Revision/Fig_Cares_ResBenef_medians_Occ','epsc');
% saveas(gcf,'Figures_Revision/Fig_Cares_ResBenef_medians_Occ','png');
% % black and white
% saveas(gcf,'Figures_Revision/Fig_Cares_ResBenef_medians_Occ_bw','eps');


